/**
 */
package Alloy.impl;

import Alloy.AlloyPackage;
import Alloy.MaterialAssociation;
import Alloy.MomentVariable;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Material Association</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link Alloy.impl.MaterialAssociationImpl#getRelator <em>Relator</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class MaterialAssociationImpl extends RelationshipImpl implements MaterialAssociation {
	/**
	 * The cached value of the '{@link #getRelator() <em>Relator</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRelator()
	 * @generated
	 * @ordered
	 */
	protected MomentVariable relator;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected MaterialAssociationImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return AlloyPackage.Literals.MATERIAL_ASSOCIATION;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public MomentVariable getRelator() {
		return relator;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetRelator(MomentVariable newRelator, NotificationChain msgs) {
		MomentVariable oldRelator = relator;
		relator = newRelator;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AlloyPackage.MATERIAL_ASSOCIATION__RELATOR, oldRelator, newRelator);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setRelator(MomentVariable newRelator) {
		if (newRelator != relator) {
			NotificationChain msgs = null;
			if (relator != null)
				msgs = ((InternalEObject)relator).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - AlloyPackage.MATERIAL_ASSOCIATION__RELATOR, null, msgs);
			if (newRelator != null)
				msgs = ((InternalEObject)newRelator).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - AlloyPackage.MATERIAL_ASSOCIATION__RELATOR, null, msgs);
			msgs = basicSetRelator(newRelator, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, AlloyPackage.MATERIAL_ASSOCIATION__RELATOR, newRelator, newRelator));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case AlloyPackage.MATERIAL_ASSOCIATION__RELATOR:
				return basicSetRelator(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case AlloyPackage.MATERIAL_ASSOCIATION__RELATOR:
				return getRelator();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case AlloyPackage.MATERIAL_ASSOCIATION__RELATOR:
				setRelator((MomentVariable)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case AlloyPackage.MATERIAL_ASSOCIATION__RELATOR:
				setRelator((MomentVariable)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case AlloyPackage.MATERIAL_ASSOCIATION__RELATOR:
				return relator != null;
		}
		return super.eIsSet(featureID);
	}

} //MaterialAssociationImpl
